/**
 * echarts图表数据格式转化
 * 后端返回格式：[{周一：120}，{周二：222}]
 * 转换后格式: {
 *     xData: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
 *     yData: [120, 200, 150, 80, 70, 110, 130]
 * }
 */

interface Data {
    key: string;
    value: string|number
}

interface Result {
    xData: string[];
    yData: any[];
}

export default function (data: Data[]):Result{
    const xData: string[] = []
    const yData: any[] = []

    data.forEach((item: Data) => {
        Object.keys(item).forEach((key: string) => {
            xData.push(key)
            yData.push(item[key])
        })
    })
    return {
        xData,
        yData
    }
}